/**
 * Company : SIANGKLOM.
 * Created By : Chatree Siangklom
 * Created On : Oct 9, 2013  5:40:29 PM 
 * e-Mail : dr_chatree@hotmail.com
 * Mobile Phone : (+66) 087-921-5115
 * Package Name : com.tis.database.services.staging.impl
 * File Name : FiInvReceiptOutbServices.java
 * TODO
 */
package com.tis.database.services.staging.impl;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import org.hibernate.HibernateException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import sap.business.enumeration.STAGING_STATUS;

import com.tis.database.dao.staging.FiInvReceiptOutbDao;
import com.tis.database.entitys.SapMessage;
import com.tis.database.entitys.staging.FiInvReceiptOutb;
import com.tis.database.entitys.staging.StampObject;
import com.tis.database.services.staging.IFiInvReceiptOutbServices;

/**
 * @author Chatree Siangklom of Administrator
 * Date =Oct 9, 2013 : 5:40:29 PM 
 * CreateBy=Chatree Siangklom
 * 
 * FiInvReceiptOutbServices
 * TODO
 */
@Service
@Transactional(readOnly=true)
public class FiInvReceiptOutbServices implements IFiInvReceiptOutbServices {
	
	private static final Logger logging = LoggerFactory.getLogger(FiInvReceiptOutbServices.class);

	@Autowired
	private FiInvReceiptOutbDao fiInvReceiptOutbDao;

	/** (Javadoc)
	 * @see com.tis.database.services.staging.IFiInvReceiptOutbServices#Search(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, int)
	 * Date =Oct 9, 2013 : 5:40:29 PM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	public List<FiInvReceiptOutb> Search(	String id, 
											String sapstagingId,
											String company,
											String project,
											String documentNo,
											String refDocNo,
											String accountCode,
											String accountCode2,
											String unitNo,
											String status,	
											String instanceNo,
											String syncIssync,
											String interfaceOnStart, 
											String interfaceOnEnd,
											int maxResult) throws HibernateException, Exception {

		return fiInvReceiptOutbDao.Search(id, sapstagingId, company, project, documentNo, refDocNo, accountCode, accountCode2, unitNo, status, instanceNo, syncIssync, interfaceOnStart, interfaceOnEnd, maxResult);
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.IFiInvReceiptOutbServices#saveOrUpdate(com.tis.database.entitys.staging.FiInvReceiptOutb)
	 * Date =Oct 9, 2013 : 5:40:29 PM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	@Transactional(readOnly=false)
	public void saveOrUpdate(FiInvReceiptOutb e) throws HibernateException, Exception {
		fiInvReceiptOutbDao.saveOrUpdate(e);
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.IFiInvReceiptOutbServices#saveOrUpdate(java.util.List)
	 * Date =Oct 9, 2013 : 5:40:29 PM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	@Transactional(readOnly=false)
	public void saveOrUpdate(List<FiInvReceiptOutb> e) throws HibernateException, Exception {

		fiInvReceiptOutbDao.saveOrUpdate(e);
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.IFiInvReceiptOutbServices#findById(java.lang.String)
	 * Date =Oct 9, 2013 : 5:40:29 PM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	@Transactional(readOnly=false)
	public FiInvReceiptOutb findById(String id) throws HibernateException, Exception {
		return fiInvReceiptOutbDao.findById(id);
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.IFiInvReceiptOutbServices#NextSequence(java.lang.String)
	 * Date =Oct 9, 2013 : 5:40:29 PM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	@Transactional(readOnly=false)
	public BigDecimal NextSequence(String name) throws HibernateException, Exception {
		return fiInvReceiptOutbDao.NextSequence(name);
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.IFiInvReceiptOutbServices#NextInstanceNo()
	 * Date =Oct 14, 2013 : 3:36:00 PM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	@Transactional(readOnly=false)
	public BigDecimal NextInstanceNo() throws HibernateException, Exception {
		
		return fiInvReceiptOutbDao.NextInstanceNo();
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.IFiInvReceiptOutbServices#UpdateBackSapMessage(java.util.List)
	 * Date =Oct 14, 2013 : 5:07:13 PM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	@Transactional(readOnly=false)
	public List<FiInvReceiptOutb> UpdateBackSapMessage(List<SapMessage> sapMessages) throws HibernateException, Exception {
		return fiInvReceiptOutbDao.UpdateBackSapMessage(sapMessages);
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.IFiInvReceiptOutbServices#NextSequence()
	 * Date =Oct 16, 2013 : 10:27:45 AM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	@Transactional(readOnly=false)
	public BigDecimal NextSequence() throws HibernateException, Exception {

		return fiInvReceiptOutbDao.NextSequence("FI_INV_RECEIPT_OUTB");
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.IFiInvReceiptOutbServices#getCurrentDatabaseDate()
	 * Date =Oct 18, 2013 : 11:50:17 AM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	public Date getCurrentDatabaseDate() throws HibernateException, Exception {

		return fiInvReceiptOutbDao.getCurrentDatabaseDate();
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.IFiInvReceiptOutbServices#StampUsedTime(com.tis.database.entitys.staging.StampObject, com.tis.database.entitys.staging.FiInvReceiptOutb)
	 * Date =Oct 18, 2013 : 11:50:17 AM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	@Transactional(readOnly=false)
	public void StampUsedTime(StampObject stampObject, FiInvReceiptOutb e) throws Exception {

		fiInvReceiptOutbDao.StampUsedTime(stampObject, e);
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.IFiInvReceiptOutbServices#StampUsedTimePROC(java.lang.String, java.util.Date, java.util.Date, com.tis.database.entitys.staging.FiInvReceiptOutb)
	 * Date =Oct 18, 2013 : 1:39:47 PM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	@Transactional(readOnly=false)
	public void StampUsedTimePROC(String instanceNo, Date procStartTime, Date procEndTime, FiInvReceiptOutb e) throws Exception {
		
		fiInvReceiptOutbDao.StampUsedTimePROC(instanceNo, procStartTime, procEndTime, e);
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.IFiInvReceiptOutbServices#StampUsedTimeSend(java.lang.String, java.util.Date, java.util.Date, com.tis.database.entitys.staging.FiInvReceiptOutb)
	 * Date =Oct 18, 2013 : 1:39:47 PM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	@Transactional(readOnly=false)
	public void StampUsedTimeSend(String instanceNo, Date sendUseStart, Date sendUseEnd, FiInvReceiptOutb e) throws Exception {
		
		fiInvReceiptOutbDao.StampUsedTimeSend(instanceNo, sendUseStart, sendUseEnd, e);
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.IFiInvReceiptOutbServices#StampUsedTimePms(java.lang.String, java.util.Date, java.util.Date, com.tis.database.entitys.staging.FiInvReceiptOutb)
	 * Date =Oct 18, 2013 : 1:39:47 PM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	@Transactional(readOnly=false)
	public void StampUsedTimePms(String instanceNo, Date pmsUseStart, Date pmsUseEnd, FiInvReceiptOutb e) throws Exception {

		fiInvReceiptOutbDao.StampUsedTimePms(instanceNo, pmsUseStart, pmsUseEnd, e);
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.IFiInvReceiptOutbServices#findByInstanceNo(java.lang.String, com.tis.database.entitys.staging.FiInvReceiptOutb)
	 * Date =Oct 18, 2013 : 2:32:54 PM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	public List<FiInvReceiptOutb> findByInstanceNo(String instanceNo, FiInvReceiptOutb e) throws HibernateException, Exception {

		return fiInvReceiptOutbDao.findByInstanceNo(instanceNo, e);
	}

	/** (Javadoc)
	 * @see com.tis.database.services.staging.IFiInvReceiptOutbServices#SaveErrorToStaging(java.lang.String, sap.business.enumeration.STAGING_STATUS, java.lang.String)
	 * Date =Oct 24, 2013 : 5:15:15 PM 
	 * CreateBy=Chatree Siangklom
	 * TODO
	 */
	@Override
	@Transactional(readOnly=false)
	public void SaveErrorToStaging(String instanceNo, STAGING_STATUS Staging_STATUS, String error) {
		fiInvReceiptOutbDao.SaveErrorToStaging(instanceNo, Staging_STATUS, error);
	}

	
}
